From 7aaa6f121b8c60c00aa7d092ad1ccb361a92dd05 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Tue, 9 Oct 2018 03:27:05 +0000 Subject: [PATCH] Allow string to be modified during parse. Ugh. --- csv_util.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/csv_util.cc b/csv_util.cc index 67854121a..ba1685ed2 100644 --- a/csv_util.cc +++ b/csv_util.cc @@ -1441,8 +1441,9 @@ xcsv_data_read(void) } if (!buff.isEmpty()) { Waypoint* wpt_tmp = new Waypoint; - - const char* s = strdup(CSTR(buff)); + // tbuf is a temporary copy of buff since we modify it. :-( + char *tbuf = xstrdup(buff); + const char* s = tbuf; s = csv_lineparse(s, CSTR(xcsv_file.field_delimiter), CSTR(xcsv_file.field_encloser), linecount); @@ -1518,6 +1519,7 @@ xcsv_data_read(void) default: ; } + xfree(tbuf); } } } -- 2.30.2